<?php
session_start();

if($_SESSION['username']==""){
	header("Location:index.php");
}
include ("db.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Administrator</title>
<link id="link"  rel="stylesheet" type="text/css" media="all"/>
<script language="javascript" src="js/prototype.js"
		type="text/javascript"></script>
<script language="javascript" src="js/common.js"
		type="text/javascript"></script>
<script language="javascript" src="js/TreeElement.js"
		type="text/javascript"></script>
<script language="javascript" src="js/DateField.js"
		type="text/javascript"></script>
<script language="javascript" src="js/global.js"
		type="text/javascript"></script>
<script language="javascript">
	var strPositionText = "Location : ";
	
	document.getElementById("link").href = "css/en_us/index.css";
</script>

</head>
<body>
<div id="autoFit">
    <div id="Header">
        <div class="Main_supporterBar" id="SupportBar"></div>
        <div class="Header_logoBar"></div>
        <div class="Header_linkBar">
            <div class="Header_linkBar_head"></div>
            <div class="Header_linkBar_body">
                <ul>
                    <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Welcome,<?=$_SESSION['username']?><span>
		    </span></li>
                    <li><a href="javascript:window.parent.location='Logout.php'">Logout</a></li>
                </ul>
            </div>
            <div class="Header_linkBar_fot"></div>
        </div>
        <div class="Header_navBar" style="display:none">
            <div class="Header_navBar_head"></div>
            <div class="Header_navBar_body">
                <ul>
                    <li class="normal" id="headerNavBar02">
                        <div class="left"></div>
                        <div class="content"></div>
                        <div class="right"></div>
                    </li>
                </ul>
            </div>
            <div class="Header_navBar_foot"></div>
        </div>
        <div class="Header_stateBar">
            <div class="Header_stateBar_head"></div>
            <div class="Header_stateBar_body"></div>
            <div class="Header_stateBar_foot"></div>
        </div>

    </div>
</div>
<div class="Main_left" id="Main_left">
    <div class="Main_shortcutsBar" id="LeftSide">
        <div class="Main_shortcutsBar_head"><span>系统管理</span></div>
        <div class="Main_shortcutsBar_body">
            <div id="MenuBox"></div>
        </div>
        <div class="Main_shortcutsBar_foot"></div>
    </div>
    <div class="Main_switchBar">
        <div class="arrowLeft" onclick="switchMainLeft(this)"></div>
    </div>
</div>

<script language="javascript" charset="utf-8">
    var crtMainMenu = "headerNavBar04";
    var category = [

        {id:"mainmenu1",text:"",    href:"javascript:void(0)"},
        {id:1,                level:1,text:"",    remark:"",    type:"root"},
		{id:11,    parent:1,    level:2,text:"Channel Define",    remark:"Channel Define",    type:"branch" ,href:"channel.php",parentlink:"1"},
        {id:12,    parent:1,    level:2,text:"Movie",    remark:"Movie",    type:"branch" ,href:"movieList.php",parentlink:"1"},
        {id:13,    parent:1,    level:2,text:"Blog",    remark:"Blog",    type:"branch" ,href:"group_list.php",parentlink:"1"},
        {id:14,    parent:1,    level:2,text:"Pic",    remark:"Pic",    type:"branch" ,href:"director_list.php",parentlink:"1"},
        {id:15,    parent:1,    level:2,text:"News",    remark:"News",    type:"branch" ,href:"#",parentlink:"1"},
        {id:16,    parent:1,    level:2,text:"Products",    remark:"Products",    type:"branch" ,href:"car_perform.php",parentlink:"1"},
    ]
    function selectNode(event) {
        var obj = $("MenuBox").getElementsByTagName("div");
        var a = $("MenuBox").getElementsByTagName("a");

        var e = window.event || event;

        var target = $(Event.element(e).id);
        crtselect = target.id;
        crtlevel = target.getAttribute("level");

        for (var j = 0; j < a.length; j++)
        {
            if (a[j].getAttribute("level") == crtlevel && a[j].id != crtselect) {
                $(a[j].id + "_subarea").style.display = "none";
                $(a[j].id).parentNode.className = $(a[j].id).parentNode.getAttribute("nclass");
            }
        }
    }
    var crtselect = "root";
    var crtlevel = 1;
    var maxlevel = 4;
    function addnode() {
        if (crtlevel >= maxlevel)
            return;
        if (!crtselect)
            return;
        var arg = new Object();
        arg.id = "node" + inc;
        arg.parent = $(crtselect + "_subarea");
        arg.text = $("txtCategoryName").value;
        arg.remark = $("txtCategoryRemark").value;
        arg.level = parseInt(crtlevel) + 1;

        if (arg.type == "branch") {
            arg.item_normal = "item_normal";
            arg.item_select = "item_select";
        } else {
            arg.item_normal = "leaf_item_normal";
            arg.item_select = "leaf_item_select";
        }
        var newnode = new TreeNode(arg);
        newnode._itemHandler = function(event) {
            selectNode(event)
        };
        inc ++;
    }
    function addCategorys(arr) {
        var arr1 = [];
        var arr2 = [];
        var arr3 = [];
        for (var i = 0; i < arr.length; i++) {
            if (arr[i].type == "root") {
                arr1.push(arr[i]);
            }
            else if (arr[i].type == "branch") {
                arr2.push(arr[i]);
            } else if (arr[i].type == "leaf") {
                arr3.push(arr[i]);
            }
        }
        addByType(arr1, "root");
        addByType(arr2, "branch");
        addByType(arr3, "leaf");
    }
    function addByType(arr, type) {
        for (var i = 0; i < arr.length; i++) {
            if (type == "root") {
                var nd = new TreeNode({id:arr[i].id,parent:$("MenuBox"),text:arr[i].text,href:arr[i].href,remark:arr[i].remark,parentlink:arr[i].parentlink,level:1,indent:0,item_normal:"root_normal",item_select:"root_select"})
                nd._itemHandler = function(event) {
                    selectNode(event)
                };
                nd._itemHandler2 = function(event) {
                    setHeight('Main_body', 'Main_left');
                }
            }
            else if (type == "branch") {
                var item_n,item_s;
                item_n = arr[i].level > 2 ? "sub_item_normal" : "item_normal";
                item_s = arr[i].level > 2 ? "sub_item_select" : "item_select";
                var nd = new TreeNode({id:arr[i].id,parent:$(arr[i].parent + "_subarea"),text:arr[i].text,href:arr[i].href,remark:arr[i].remark,parentlink:arr[i].parentlink,level:arr[i].level,item_normal:item_n,item_select:item_s})
                nd._itemHandler = function(event) {
                    selectNode(event)
                };
                nd._itemHandler2 = function(event) {
                    setHeight('Main_body', 'Main_left');
                }
            }
            else if (type == "leaf") {
                    var nd = null;
                    if (arr[i].level == 4)
                        nd = new TreeNode({id:arr[i].id,parent:$(arr[i].parent + "_subarea"),text:arr[i].text,href:arr[i].href,remark:arr[i].remark,parentlink:arr[i].parentlink,level:arr[i].level,item_normal:"menu_item_normal4",item_select:"menu_item_select4"})
                    else
                        nd = new TreeNode({id:arr[i].id,parent:$(arr[i].parent + "_subarea"),text:arr[i].text,href:arr[i].href,remark:arr[i].remark,parentlink:arr[i].parentlink,level:arr[i].level,item_normal:"leaf_item_normal",item_select:"leaf_item_select"})
                    nd._itemHandler = function(event) {
                        selectNode(event)
                    };
                    nd._itemHandler2 = function(event) {
                        setHeight('Main_body', 'Main_left');
                    }
                }
        }
    }
</script>
</body>
</html>